<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public:header2" />
    <title>{:C('web_title')}</title>
</head>
<body class="blackbg">
    <div id="container" class="logbg">
        <div class="log_title">
            <span class="back"><a href="javascript:history.go(-1)"></a></span>
            {$Think.lang.g_mibao_pwd}
        </div>
        <div class="logbot">
			<!--<div class="reghd">
				<ul>
					<li class="selbut on" id="mobile_fpw">手机找回</li>
					<li class="selbut on" id="email_fpw">邮箱找回</li>
				</ul>
			</div>-->
			<!--<div id="mobile_div">
				<input type="text" placeholder="手机号" class="logipt" id="mobile" name="mobile" onblur="fpwmobile();" />
			</div>-->
			<div id="email_div">
				<input type="text" placeholder="{$Think.lang.g_dz_yx}" class="logipt"  id="email" name="email" onblur="fpwemail();" />
			</div>
			<div class="yzmbox">
				<input type="text" class="logipt yzmipt"  id="verify" name="code" placeholder="{$Think.lang.g_yzm}" onblur="fpwverify();"/>
				<img id="codeImg" src="{:U('Verify/code')}" onclick="this.src=this.src+'?t='+Math.random()" class="codeImg" title="{$Think.lang.Finance_yzmhyz}">
			</div>
			<!--<div class="yzmbox" id="myz_div">
				<input type="text" placeholder="短信验证码" class="logipt yzmipt" id="mobile_verify" name="code" onblur="inputcode();" maxlength="6"/>
				<input type="button" class="phonebut" value="点击获取验证码" onclick="SendCode()" id="regBtn" />
			</div>-->
			<div class="yzmbox" id="eyz_div">
				<input type="text" placeholder="{$Think.lang.g_yx_verify}" class="logipt yzmipt" id="email_verify" name="code" onblur="emailcode();" maxlength="6"/>
				<input type="button" class="phonebut" value="{$Think.lang.Finance_hqyzm2}" onclick="EmCode()" id="regBtn" />
			</div>
			<div id="usemibao" style="display:none;">
				<select id="mibao_question" class="logipt">
					<option value="">{$Think.lang.User_xzmbwt}</option>
					<option value="你父亲的姓名">{$Think.lang.User_father}</option>
					<option value="你母亲的姓名">{$Think.lang.User_mather}</option>
					<option value="你爱人的姓名">{$Think.lang.User_love}</option>
					<option value="你的出生日期">{$Think.lang.User_birthday}</option>
					<option value="你父亲的出生日期">{$Think.lang.User_fatherday}</option>
					<option value="你母亲的出生日期">{$Think.lang.User_matherday}</option>
					<option value="你爱人的出生日期">{$Think.lang.User_loveday}</option>
				</select>
				<input type="text" id="mibao_answer" class="logipt" placeholder="{$Think.lang.User_wtda}" />
				<!--<p class="attention">
					{$Think.lang.Login_wj1}
					<a href="tencent://message/?uin={$C['contact_qq'][1]}&Site=&Menu=yes" style="color:#e76500">
						{$Think.lang.Login_zxkf}
					</a>
					{$Think.lang.Login_wj2}
				</p>-->
			</div>
			
			<input type="password" placeholder="{$Think.lang.Login_xdlmm}" class="logipt"  id="password" name="password" onkeyup="chkpwd();" maxlength="16"/>
			
			<input type="password" placeholder="{$Think.lang.Login_qrdlmm}" class="logipt"  id="repassword" name="password" onkeyup="chkrepwd();" maxlength="16"/>
			
			<input type="hidden" id="fpw_type" value="phone" />
			<input type="hidden" id="isusemibao" value="0" />

			<input type="button" class="logbut" value="{$Think.lang.User_enterxgmm}"  name="index_submit" id="Submin" onclick="Update();" />
        </div>
    </div>
<script type="text/javascript">
    function SendCode(){
        var mobile=$("#mobile").val();
        var verify=$("#verify").val();
        if(mobile==""||mobile==null){
            layer.tips('请输入手机号码','#mobile',{tips:3});
            return false;
        }
        if(verify==""||verify==null){
            layer.tips('请输入图形验证码','#verify',{tips:3});
            return false;
        }
        layer.load(0, {shade: [0.5,'#8F8F8F']});
        $.post("{:U('Verify/findpwd')}",{mobile:mobile,verify:verify},function(data){
            layer.closeAll();
            if(data.status==1){
                $('#regBtn').attr("disabled","disabled");
                layer.msg(data.info,{icon:1});
                var obj=$('#regBtn');
                var wait=120;
                var interval=setInterval(function(){
                    obj.css('backgroundColor','#f6f6f6');
                    obj.val('（'+wait+'）秒后再次发送');
                    wait--;
                    if(wait<0){
                        obj.removeAttr("disabled");
                        clearInterval(interval);
                        obj.val('获取验证码');
                        obj.css('backgroundColor','#f6f6f6');
                    }
                    ;
                },1000);
            }else{
                $('#regBtn').removeAttr("disabled");
                layer.msg(data.info,{icon:2});
            }
        },"json");
    }

	function EmCode(){
		var email = $("#email").val();
        if (email == "" || email == null) {
            layer.tips('{$Think.lang.g_yx_put}', '#email', {tips: 3});
            return false;
        }
		var verify = $('#verify').val();
		if(verify==""||verify==null){
			layer.tips('{$Think.lang.g_put_tcode}', '#verify', {tips: 3});
			return false;
		}
		layer.load(0, {shade: [0.5,'#8F8F8F']});
        $.post("{:U('Verify/findpwdemail')}", {
            email: email,verify: verify
        }, function (data) {
			layer.closeAll();
            if (data.status == 1) {
                //刷新验证码
                $('#regBtn').attr("disabled", "disabled");
                layer.msg(data.info, {icon: 1});
                var obj = $('#regBtn');
                var wait = 60;
                var interval = setInterval(function () {
                    obj.css('backgroundColor', '#f6f6f6');
                    obj.val(wait + '{$Think.lang.sFinance_myzc_mzcfs}');
                    wait--;
                    if (wait < 0) {
                    	$('#regBtn').removeAttr("disabled");
                        clearInterval(interval);
                        obj.val('{$Think.lang.sFinance_myzc_hqyzm}');
                        obj.css('backgroundColor', '#f6f6f6');
                    }
                    ;
                }, 1000);
            } else {
                //刷新验证码
                layer.msg(data.info, {icon: 2});
                $('#regBtn').removeAttr("disabled");
                if (data.url) {
                    window.location = data.url;
                }
            }
        }, "json");
	}

    function Update(){
		var fpw_type = 'emailaddr';
		if(fpw_type != 'phone' && fpw_type != 'emailaddr'){
			layer.msg('参数错误！',{icon:2});
		}
		var isusemibao = $("#isusemibao").val();
        //var mobile=$("#mobile").val();
        //var mobile_verify=$("#mobile_verify").val();
        var verify=$("#verify").val();
        var password=$("#password").val();
        var repassword=$("#repassword").val();
        var mibao_question=$("#mibao_question").val();
        var mibao_answer=$("#mibao_answer").val();
		var email=$("#email").val();
		var emailcode=$("#email_verify").val();
        /*if((mobile==""||mobile==null) && fpw_type == 'phone'){
            layer.tips('请输入手机号码','#mobile',{tips:3});
            return false;
        }
        if((mobile_verify==""||mobile_verify==null) && fpw_type == 'phone'){
            layer.tips('请输入短信验证码','#mobile_verify',{tips:3});
            return false;
        }*/
		if ((email == "" || email == null) && fpw_type == 'emailaddr') {
            layer.tips('{$Think.lang.g_yx_put}', '#email', {tips: 3});
            return false;
        }
		if((emailcode==""||emailcode==null) && fpw_type == 'emailaddr'){
			layer.tips('{$Think.lang.g_yx_put_verfy}','#email_verify',{tips:3});
			return false;
		}
        if(verify==""||verify==null){
            layer.tips('{$Think.lang.User_txyzm}','#verify',{tips:3});
            return false;
        }
        if((mibao_question==""||mibao_question==null) && isusemibao>0){
            layer.tips('{$Think.lang.choose_code_que}','#mibao_question',{tips:3});
            return false;
        }
        if((mibao_answer==""||mibao_answer==null) && isusemibao>0){
            layer.tips('{$Think.lang.input_que_ans}','#mibao_answer',{tips:3});
            return false;
        }
        if(password==""||password==null){
            layer.tips('{$Think.lang.Finance_srdlmm}','#password',{tips:3});
            return false;
        }
        if(repassword==""||repassword==null){
            layer.tips('{$Think.lang.Login_srqrmm}','#repassword',{tips:3});
            return false;
        }
        if(password!=repassword){
            layer.tips('{$Think.lang.two_code_diff}','#repassword',{tips:3});
            return false;
        }
        $.post("{:U('Login/findpwd')}",{fpw_type:fpw_type,isusemibao:isusemibao,verify:verify,password:password,repassword:repassword,mibao_question:mibao_question,mibao_answer:mibao_answer,email:email,emailcode:emailcode},function(data){
            if(data.status==1){
                layer.msg(data.info,{icon:1});
                window.setTimeout("window.location='{:U('Login/index')}'",1000);
            }else{
                layer.msg(data.info,{icon:2});
            }
        },"json");
    }
	function fpwmobile(){
		var mobile = $('#mobile').val();
		if(mobile==""||mobile==null||(mobile!=null&&mobile.length<11)){
			layer.tips('请输入正确的手机号','#mobile',{tips:3});
			return false;
		}
		$.post("{:U('Login/chkusemibao')}",{mobile:mobile},function(data){
			if(!data.status){
				layer.tips(data.info,'#mobile',{tips:3});
			}else{
				if(data.usemibao && data.usemibao>0){
					$("#isusemibao").val(1);
					$("#usemibao").show();
				}
			}
		},'json');
	}
	function fpwemail(){
		var email = $('#email').val();
		if(email==""||email==null){
			layer.tips('{$Think.lang.g_yx_puts}','#email',{tips:3});
			return false;
		}
		$.post("{:U('Login/chkusemibao')}",{email:email},function(data){
			if(!data.status){
				layer.tips(data.info,'#email',{tips:3});
			}else{
				if(data.usemibao && data.usemibao>0){
					$("#isusemibao").val(1);
					$("#usemibao").show();
				}
			}
		},'json');
	}
	$("#mibao_answer").focus(function(){
		var mibao_question = $("#mibao_question").val();
		if(!mibao_question){
			layer.tips('{$Think.lang.choose_code_que}','#mibao_question',{tips:3});
			return false;
		}
	});
	$("#mibao_answer").blur(function(){
		if($(this).val()==''||$(this).val()==null){
			layer.tips('{$Think.lang.input_que_ans}','#mibao_answer',{tips:3});
			return false;
		}
	});
	function fpwverify(){
		var verify = $('#verify').val();
		if(verify==""||verify==null){
			layer.tips('{$think.lang.User_txyzm}','#verify',{tips:3});
			return false;
		}
	}
	function inputcode(){
		var mobileverify = $("#mobile_verify").val();
		if(mobileverify==""||mobileverify==null){
			layer.tips('{$Think.lang.Finance_dxyzm2}！','#mobile_verify',{tips:3});
			return false;
		}
	}
	function emailcode(){
		var emailcode = $("#email_verify").val();
		if(emailcode==""||emailcode==null){
			layer.tips('{$Think.lang.g_yx_put_verfy}','#emailcode',{tips:3});
			return false;
		}
	}
	function chkpwd(){
		var password = $("#password").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(password)) {
			layer.tips('{$Think.lang.User_mmgs2}','#password',{tips:3});
			var result = password.substring(0,password.length-1);
			$("#password").val(result);
		}
	}
	function chkrepwd(){
		var repassword = $("#repassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(repassword)) {
			layer.tips('{$Think.lang.User_mmgs2}','#repassword',{tips:3});
			var result = repassword.substring(0,repassword.length-1);
			$("#repassword").val(result);
		}
	}
	$("#mobile_fpw").click(function(){
		$(this).attr("class","selbut on");
		$("#mobile_div").show();
		$("#myz_div").show();
		$("#fpw_type").val("phone");
		$("#email_fpw").attr("class","selbut");
		$("#email_div").hide();
		$("#eyz_div").hide();
	});
	$("#email_fpw").click(function(){
		$(this).attr("class","selbut on");
		$("#mobile_div").hide();
		$("#myz_div").hide();
		$("#fpw_type").val("emailaddr");
		$("#mobile_fpw").attr("class","selbut");
		$("#email_div").show();
		$("#eyz_div").show();
	});
</script>
</body>
</html>